package fem2.pre_and_post;

import java.util.ArrayList;

import org.junit.Test;

import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.pre_and_post.GidMeshGenerator;
import fem2.pre_and_post.GmshMeshGenerator;

public class MeshReaderTest {

	@Test
	public void testGid() {
		MeshGenerator r = new GidMeshGenerator(
				"/home/hbui/kratos_janosch/Lbeam.gid/Lbeam.msh");

		ArrayList<double[]> nodes = null;
		nodes = r.getNodes(2);
		for (double[] v : nodes)
			System.out.println(v[0] + ", " + v[1]);

		ArrayList<ArrayList<Integer>> elements = null;
		elements = r.getConnectivities();
		for (ArrayList<Integer> e : elements) {
			for (int i : e)
				System.out.print(i + " ");
			System.out.println();
		}
	}

	@Test
	public void testGmsh() {
		MeshGenerator r = new GmshMeshGenerator(
				"/home/hbui/kratos_janosch/Lbeam2.gmsh/Lbeam2.msh");

		ArrayList<double[]> nodes = null;
		nodes = r.getNodes(2);
		System.out.println("number of nodes: " + nodes.size());
		for (double[] v : nodes)
			System.out.println(v[0] + ", " + v[1]);

		ArrayList<ArrayList<Integer>> elements = null;
		elements = r.getConnectivities();
		System.out.println("number of elements: " + elements.size());
		for (ArrayList<Integer> e : elements) {
			for (int i : e)
				System.out.print(i + " ");
			System.out.println();
		}
	}

	@Test
	public void testGmsh2() {
		MeshGenerator r = new GmshMeshGenerator(
				"/home/hbui/kratos_janosch/Lbeam2.gmsh/Lbeam2.msh");
		Mesh mesh = r.getMesh(2);
		mesh.Print();
	}
}
